Tham khảo chéo hệ thống lựa chọn Điều_kiện_(lập_trình_máy_tính)

Bảng này đề cập đến đặc tả ngôn ngữ gần đây nhất của mỗi ngôn ngữ. Đối với các ngôn ngữ không có thông số kỹ thuật, việc triển khai chính thức mới nhất được đề cập đến.

Programming languageStructured ifswitch–select–caseArithmetic ifPattern matching[A]
thenelseelse–if
AdaKhôngKhông
Bash shellKhông
C, C++Unneeded[B]Fall-throughKhôngKhông
C#Unneeded[B]KhôngKhông
COBOLUnneeded[B]KhôngKhông
EiffelYesKhôngKhông
F#Unneeded[C]Không
Fortran 90[F]Không
GoUnneeded[B]KhôngKhông
HaskellNeededUnneeded[B]Bản mẫu:Yes-no[C]Không
JavaUnneeded[B]Fall-through[1]KhôngKhông
ECMAScript (JavaScript)Unneeded[B]Fall-through[2]KhôngKhông
MathematicaKhông
OberonKhôngKhông
PerlKhôngKhông
PHPFall-throughKhôngKhông
Pascal, Object Pascal (Delphi)UnneededKhôngKhông
PythonKhôngKhôngKhông
QuickBASICKhôngKhông
RubyKhôngKhông
RustUnneededKhông
ScalaUnneeded[B]Fall-through[cần dẫn nguồn]Không
SQL[S][S]KhôngKhông
SwiftKhông
Visual Basic, classicKhôngKhông
Visual Basic.NETKhôngKhông
Windows PowerShellFall-throughKhôngKhông
  1. ^ This refers to pattern matching as a distinct conditional construct in the programming language – as opposed to mere string pattern matching support, such as regular expression support.
  2. 1 2 3 4 5 The often-encountered else if in the C family of languages, and in COBOL and Haskell, is not a language feature but a set of nested and independent if then else statements combined with a particular source code layout. However, this also means that a distinct else–if construct is not really needed in these languages.
  3. 1 2 In Haskell and F#, a separate constant choice construct is unneeded, because the same task can be done with pattern matching.
  4. ^ In a Ruby case construct, regular expression matching is among the conditional flow-control alternatives available. For an example, see this Stack Overflow question.
  5. 1 2 SQL has two similar constructs that fulfill both roles, both introduced in SQL-92. A "searched CASE" expression CASE WHEN cond1 THEN expr1 WHEN cond2 THEN expr2 [...] ELSE exprDflt END works like if ... else if ... else, whereas a "simple CASE" expression: CASE expr WHEN val1 THEN expr1 [...] ELSE exprDflt END works like a switch statement. For details and examples see Case (SQL).
  6. ^ Arithmetic if is obsolescent in Fortran 90.